define(['app',],function(app){return {module: function($scope, $http, eventBusService, httpService, params, configService) {
	//JS校验form表单信息  
	$scope.checkData = function(){
		
           var fileDir = $("#upfile").val();  
           var suffix = fileDir.substr(fileDir.lastIndexOf("."));  
           if("" == fileDir){  
               eventBusService.publish('modal.alert', {"title":"信息提示","content":"选择需要导入的Excel文件"});
               return false;  
           }  
           if(".xls" != suffix && ".xlsx" != suffix ){ 
        	   eventBusService.publish('modal.alert', {"title":"信息提示","content":"选择Excel格式的文件导入"});
        	   return false;  
           }  
           return true;  
           
    }
	$scope.save = function(){
		if(!$scope.checkData()){
			return;
		}
		
		var formData = new FormData($("#uploadForm")[0]);
		formData.append("formData",JSON.stringify($scope.form));
		$('#import').css("display", "none");
		$('.fixed').css("display", "inline-block");
		eventBusService.publish("modal.alert",{"content":"是否覆盖？","isAutoClose":false,"confirm":function(){
			$.ajax({
				url:app.urls.student_Updatexj,
				type:"POST",
				data: formData,
				processData: false,
				contentType: false,
				success:function(data){
					$('.fixed').css("display", "none");
					if(data.code == "4444") {
						$('#error').css("display", "block");
						$scope.error = data.data;
						$scope.$apply();
					}else{

						eventBusService.publish("modal.page.close",{});
						eventBusService.publish("content.page.reload",data.data);
					}
				},
				error:function(data){
					$('.fixed').css("display", "none");
					eventBusService.publish('modal.alert', {"title":"信息提示","content":"导入失败"});
					eventBusService.publish("content.page.reload",data.data);
					eventBusService.publish("modal.page.close",{});
				}
			});
			
		},"cancel":function(){
			
			$.ajax({
				url:app.urls.student_import,   
				type:"POST",
				data: formData,
				processData: false,
				contentType: false,
				success:function(data){
					$('.fixed').css("display", "none");
					if(data.code == "4444") {
						$('#error').css("display", "block");
						$scope.error = data.data;
						$scope.$apply();
					}else{
						eventBusService.publish("modal.page.close",{});
						eventBusService.publish("content.page.reload",data.data);
					}
				},
				error:function(data){
					$('.fixed').css("display", "none");
					eventBusService.publish('modal.alert', {"title":"信息提示","content":"导入失败"});
					eventBusService.publish("content.page.reload",data.data);
					eventBusService.publish("modal.page.close",{});
				}
			});
		}});
	}
	$('#import').css("display", "block");
	$scope.close = function(str){
		if(str == '1') {
		}else{
			$('#error').css("display", "none");
			$('#import').css("display", "block");
		}
		eventBusService.publish("modal.page.close",{});
	}
}}});